package ru.eas.structure;

import java.util.Scanner;

/**
 * @author aesipov
 */
public class SegmentTree {

    public static void main(String[] args) {
//        String testString = "5 7\n" +
//                "1 2 3 4 5\n" +
//                "Min 1 5\n" +
//                "Set 1 8\n" +
//                "Min 1 5\n" +
//                "Min 1 1\n" +
//                "Min 1 3\n" +
//                "Set 3 1\n" +
//                "Min 2 4";
//        Scanner scanner = new Scanner(testString);

        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int commandCount = scanner.nextInt();
        int[] array = new int[n];

        for (int i = 0; i < n; i++) {
            array[i] = scanner.nextInt();
        }

        SegmentTree segmentTree = new SegmentTree(array);

        for (int i = 0; i < commandCount; i++) {
            String command = scanner.next();
            if ("Min".equals(command)) {
                int left = scanner.nextInt();
                int right = scanner.nextInt();
                System.out.println(segmentTree.getMin(1, left, right));
            } else if ("Set".equals(command)) {
                int index = scanner.nextInt();
                int value = scanner.nextInt();
                segmentTree.set(index, value);
            }
        }
    }

    // 0 index isn't used
    private int[] data;
    private int[] leftBounds;
    private int[] rightBounds;

    private final int powerOf2;

    public SegmentTree(int[] array) {
        powerOf2 = nextPowerOf2(array.length);
        this.data = new int[2 * powerOf2];
        this.leftBounds = new int[2 * powerOf2];
        this.rightBounds = new int[2 * powerOf2];

        for (int i = 0; i < data.length; i++) {
            data[i] = Integer.MAX_VALUE;
        }
        for (int i = 0; i < array.length; i++) {
            int index = powerOf2 + i;
            data[index] = array[i];
        }
        for (int i = powerOf2 - 1; i >= 0; i--) {
            calcMin(i);
        }
        calcBounds(1, 1, powerOf2);
    }

    private void calcBounds(int index, int left, int right) {
        leftBounds[index] = left;
        rightBounds[index] = right;

        int leftIndex = left(index);
        int rightIndex = right(index);
        if (leftIndex >= data.length || rightIndex >= data.length) {
            return;
        }

        int floorMiddle = (left + right) / 2;
        calcBounds(leftIndex, left, floorMiddle);
        calcBounds(rightIndex, floorMiddle + 1, right);
    }

    private void calcMin(int index)
    {
        data[index] = Math.min(data[left(index)], data[right(index)]);
    }

    public int getMin(int index, int left, int right)
    {
        if (left > right) {
            throw new IllegalArgumentException("left shouldn't be great than right");
        }

        int leftBound = leftBounds[index];
        int rightBound = rightBounds[index];
        if (left == leftBound && right == rightBound) {
            return data[index];
        }

        int leftIndex = left(index);
        if (right <= rightBounds[leftIndex]) {
            return getMin(leftIndex, left, right);
        }

        int rightIndex = right(index);
        if (left >= leftBounds[rightIndex]) {
            return getMin(rightIndex, left, right);
        }

        int leftMin = getMin(leftIndex, left, rightBounds[leftIndex]);
        int rightMin = getMin(rightIndex, leftBounds[rightIndex], right);
        return Math.min(leftMin, rightMin);
    }

    private int left(int index)
    {
        return 2 * index;
    }

    private int right(int index)
    {
        return 2 * index + 1;
    }

    public int nextPowerOf2(int a)
    {
        int b = 1;
        while (b < a)
        {
            b = b << 1;
        }
        return b;
    }

    private void set(int index, int value) {
        int dataIndex = powerOf2 + index - 1;
        data[dataIndex] = value;
        updateBranch(parent(dataIndex));
    }

    private void updateBranch(int index) {
        calcMin(index);
        if (index != 1) {
            updateBranch(parent(index));
        }
    }

    private int parent(int index) {
        return index / 2;
    }
}
